/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package com.myapp.struts.prepare;

//~--- non-JDK imports --------------------------------------------------------

import com.myapp.struts.actionform.AccountHeadFormBean;
import com.myapp.struts.beans.AccountHeadBean;

//~--- JDK imports ------------------------------------------------------------

import java.sql.*;

import java.util.*;

//class to get arraylist
public class AccountHeadPrepareAL
 {
    // instance variable declaration
    ArrayList al = new ArrayList();

//  method to get arraylist
    public ArrayList prepareArrayList(ResultSet rs) {
        try {
            if (rs == null) {}    // end of if
            else {
                while (rs.next()) {
                    AccountHeadFormBean ahb = new AccountHeadFormBean();

                    ahb.setAccountHeadNumber(rs.getString(1));
                    ahb.setAccountHeadName(rs.getString(2));
                    ahb.setAccountHeadType(rs.getString(3));
                    ahb.setOpeningBalance(Double.parseDouble(rs.getString(5)));
                    ahb.setSchedule(rs.getString(6));
                    ahb.setBalanceType(rs.getString(7));
                    ahb.setDescription(rs.getString(8));
                    al.add(ahb);
                }                 // end of while
            }                     // end of else
        }                         // end of try
                catch (Exception e) {
            System.out.println("exception at AccountHeadPrepareAL" + e);
        }                         // end of catch

        return al;
    }    // end of arraylist method

    public ArrayList aheadName(ResultSet rs) {
        try {
            if (rs == null) {}    // end of if
            else {
                while (rs.next()) {
                    AccountHeadBean ahb = new AccountHeadBean();

                    ahb.setAhead_Name(rs.getString(1));
                    al.add(ahb);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return al;
    }

    public ArrayList cashBalance(ResultSet rs) {
        try {
            if (rs == null) {}    // end of if
            else {
                while (rs.next()) {
                    System.out.print("!!!!!!@@@" + rs.getString(1));

                    AccountHeadBean ahb = new AccountHeadBean();

                    ahb.setOpening_Balance(rs.getString(1));
                    al.add(ahb);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return al;
    }
}    // end of class

